package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.FaultRepair;
import com.ruoyi.system.mapper.FaultRepairMapper;
import com.ruoyi.system.service.IFaultRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备故障报修记录Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-19
 */
@Service
public class FaultRepairServiceImpl implements IFaultRepairService {
    @Autowired
    private FaultRepairMapper faultRepairMapper;

    /**
     * 查询设备故障报修记录
     *
     * @param repairCode 设备故障报修记录主键
     * @return 设备故障报修记录
     */
    @Override
    public FaultRepair selectFaultRepairByRepairCode(String repairCode) {
        return faultRepairMapper.selectFaultRepairByRepairCode(repairCode);
    }

    /**
     * 查询设备故障报修记录列表
     *
     * @param faultRepair 设备故障报修记录
     * @return 设备故障报修记录
     */
    @Override
    public List<FaultRepair> selectFaultRepairList(FaultRepair faultRepair) {
        return faultRepairMapper.selectFaultRepairList(faultRepair);
    }

    /**
     * 新增设备故障报修记录
     *
     * @param faultRepair 设备故障报修记录
     * @return 结果
     */
    @Override
    public int insertFaultRepair(FaultRepair faultRepair) {
        faultRepair.setCreateTime(DateUtils.getNowDate());
        return faultRepairMapper.insertFaultRepair(faultRepair);
    }

    /**
     * 修改设备故障报修记录
     *
     * @param faultRepair 设备故障报修记录
     * @return 结果
     */
    @Override
    public int updateFaultRepair(FaultRepair faultRepair) {
        faultRepair.setUpdateTime(DateUtils.getNowDate());
        return faultRepairMapper.updateFaultRepair(faultRepair);
    }

    /**
     * 批量删除设备故障报修记录
     *
     * @param repairCodes 需要删除的设备故障报修记录主键
     * @return 结果
     */
    @Override
    public int deleteFaultRepairByRepairCodes(String[] repairCodes) {
        return faultRepairMapper.deleteFaultRepairByRepairCodes(repairCodes);
    }

    /**
     * 删除设备故障报修记录信息
     *
     * @param repairCode 设备故障报修记录主键
     * @return 结果
     */
    @Override
    public int deleteFaultRepairByRepairCode(String repairCode) {
        return faultRepairMapper.deleteFaultRepairByRepairCode(repairCode);
    }
}
